package org.example.service;

import org.apache.commons.lang3.StringUtils;
import org.example.aplipayCommon.AlipayService;
import org.example.domain.PayAlipayInfo;
import org.example.domain.PayAlipayInfo;
import org.example.dto.PayDto;
import org.example.mapper.PayAlipayInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class AlipayInfoServiceImpl {

    @Autowired
    private PayAlipayInfoMapper payAlipayInfoMapper;

    @Autowired
    private AlipayService alipayService;


    public PayAlipayInfo loadByAppid(String app_id) {
        return payAlipayInfoMapper.loadByAppid(app_id);
    }

    /**
     * 用来进行跳转到  二维码生成的页面
     *
     * @param dto
     * @return
     */
    public String goBuy(PayDto dto) {
        if (StringUtils.isAnyBlank(dto.getSubject(), dto.getSubjectDesc()) || dto.getMoney() == null || dto.getShopId() == null) {
            System.out.println(">>>>>>>>>>>>>缺少必传参数");
            return "<h1>缺少必传参数</h1>";
        }
        return alipayService.createPayUrl(dto.getMoney(), dto.getSubjectDesc(), dto.getShopId());


    }
}
